// 获取元素
const modal = document.getElementById('modal');
const openModalBtn = document.getElementById('openModalBtn');
const closeModal = document.getElementById('closeModal');
const studentForm = document.getElementById('studentForm');

// 打开弹窗
openModalBtn.addEventListener('click', () => {
    modal.style.display = 'block';
});

// 关闭弹窗
closeModal.addEventListener('click', () => {
    modal.style.display = 'none';
});

// 点击弹窗外部关闭弹窗
window.addEventListener('click', (event) => {
    if (event.target === modal) {
        modal.style.display = 'none';
    }
});

// 表单提交处理
studentForm.addEventListener('submit', (event) => {
    event.preventDefault();
    const name = document.getElementById('name').value;
    const age = document.getElementById('age').value;
    const grade = document.getElementById('grade').value;
    const email = document.getElementById('email').value;
    // 这里可以将数据发送到服务器进行更新，例如使用fetch API
    console.log('姓名：', name);
    console.log('年龄：', age);
    console.log('年级：', grade);
    console.log('邮箱：', email);
    // 关闭弹窗
    modal.style.display = 'none';
});